<template>
  <div class="forecast">
    <img src="../../../assets/chart-data-bg.png" />
    <div class="title">
      <div class="title-left">
        <span>超前地质预报工作进展</span>
        <img src="../../../assets/show-title-bg.png" />
      </div>
    </div>

    <div class="percentage">
      <span>不良地质体长度</span>
      <span @click="toadvanceinfo">{{number}}米</span>
      <i></i>
      <img src="../../../assets/percentage-bg.png" />
    </div>

    <div class="forecast-data">
      <div :style="{ zoom: zoom }" id="right-2" class="forecast-data-view"></div>
    </div>
  </div>
</template>

<script>
import api from "../../../api";
import * as echarts from "echarts";
export default {
  name: "",
  components: {},
  data() {
    return {
      myChart: {},
      zoom: 1,
      number:0
    };
  },
  mounted() {
    this.$bus.$on("forecast", (row) => {
      // 超前地址预报
      api
        .bigdataAdvancedGeology({ tid: row })
        .then((res) => {
          if (res.data.code == 2001) {
            this.$charts.advancedGeology("right-2", res.data.data);
          }
        })
        .catch((err) => {
          console.log(err);
        });
        api
        .bigdatagetgetAdvancedGeologyNumber({ tid: row })
        .then((res) => {
          if (res.data.code == 2001) {
            this.number = res.data.data
          }
        })
        .catch((err) => {
          console.log(err);
        });
    });
  },
  methods: {
    chartInit() {
      let chartDom = document.querySelector(".forecast-data-view");
      this.myChart = echarts.init(chartDom);
      let option;
      option = {
        legend: {
          textStyle: {
            fontSize: 14,
            color: "#ffffff",
          },
          bottom: 3,
          data: ["上周", "本月", "今日"],
        },
        tooltip: {},
        dataset: {
          source: [
            ["product", "2015", "2016", "2017"],
            ["哈数据库", 43.3, 85.8, 93.7],
            ["阿松大", 83.1, 73.4, 55.1],
            ["2014", 86.4, 65.2, 82.5],
            ["2015", 72.4, 53.9, 39.1],
            ["2016", 72.4, 53.9, 39.1],
          ],
        },
        grid: {
          top: "30",
          left: "10",
          right: "10",
          bottom: "30",
          containLabel: true,
        },
        xAxis: { type: "category" },
        yAxis: [
          {
            type: "value",
            name: "",
            min: 0,
            max: 250,
            interval: 50,
            axisLabel: {
              formatter: "{value} 万",
            },
          },
        ],
        series: [
          {
            name: "上周",
            barWidth: 10,
            type: "bar",
            itemStyle: { color: "#4c8fe7" },
          },

          {
            name: "本月",
            barWidth: 10,
            type: "bar",
            itemStyle: { color: "#5b39ea" },
          },
          {
            name: "今日",
            barWidth: 10,
            type: "bar",
            itemStyle: { color: "#68da98" },
          },
        ],
      };

      option && this.myChart.setOption(option);
    },
    toadvanceinfo(){
      this.$router.push({ path: "/system/syswarnlog" })
    }
  },
};
</script>

<style lang="scss" scoped>
.forecast {
  width: 100%;
  height: 35%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;

  > img {
    width: 100%;
    height: 80%;
    position: absolute;
    left: 0;
    bottom: 0;
  }

  > .title {
    width: 100%;
    height: 43px;
    padding-right: 30px;
    position: relative;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;

    > span {
      color: #cecece;
      font-size: 18px;
    }

    > .title-left {
      flex: 1;
      height: 43px;
      display: flex;
      align-items: center;
      padding-left: 60px;
      position: relative;
      > img {
        width: 218px;
        height: 43px;
        position: absolute;
        left: 0;
        top: 0;
      }

      > span {
        position: relative;
        color: #fff;
        font-size: 18px;
      }
    }
  }

  > .percentage {
    width: 100%;
    height: px;
    margin-top: 10px;
    padding-left: 20px;
    padding-right: 40px;
    box-sizing: border-box;
    display: flex;
    position: relative;
    justify-content: space-between;
    align-items: center;

    > i {
      width: 10px;
      height: 107%;
      display: block;
      background-color: #ee8542;
      position: absolute;
      left: 0;
      top: 0;
    }

    > img {
      width: 219px;
      height: 40px;
      position: absolute;
      left: 10px;
      top: 0;
    }

    > span {
      position: relative;
      z-index: 99;
      cursor:pointer;
    }

    > span:nth-child(1) {
      font-size: 18px;
      color: #fff;
    }

    > span:nth-child(2) {
      font-size: 28px;
      color: #ff8b3e;
      font-weight: 700;
    }
  }

  > .forecast-data {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
    .forecast-data-view {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
